// ? 系统全局字典

/**
 * @description：用户性别
 */
export const genderType = [
  { label: "男", value: 1 },
  { label: "女", value: 2 }
];

/**
 * @description：用户状态
 */
export const userStatus = [
  { label: "启用", value: 1, tagType: "success" },
  { label: "禁用", value: 0, tagType: "danger" }
];

export const enum DialogType {
  show,
  edit,
  add,
  delete,
  Null
}

export const ColumnType = [
  // date 日期型，string字符串型，number数字型,primary 主键
  { label: "日期型", value: "date" },
  { label: "字符串", value: "string" },
  { label: "数字型", value: "number" }
];

export const enum ColumnOptionsType {
  link_table,
  custom,
  null
}

export enum DimensionExtraEnum {
  normal = "normal",
  dimension_primary_key = "primary_key",
  indicators_input = "input",
  indicators_textarea = "textarea",
  indicators_richText = "richText",
  indicators_image = "image",
  indicators_file = "file",
  indicators_password = "password",
  agg_count = "COUNT",
  agg_distinct_count = "DISTINCT_COUNT",
  agg_sum = "SUM",
  agg_max = "MAX",
  agg_avg = "AVG",
  agg_min = "MIN"
}

// "EQ" | "GE" | "GT" | "IN" | "IS_NOT_NULL" | "IS_NULL" | "LE" | "LIKE" | "LT" | "NE" | "NOT_IN" | "NOT_LIKE";
export const SqlKeyword = {
  EQ: "=",
  GT: ">",
  GE: ">=",
  LT: "<",
  LE: "<=",
  NE: "!=",
  IS_NOT_NULL: "不为空",
  IS_NULL: "为空",
  IN: "在..内",
  NOT_IN: "不在..内",
  LIKE: "像",
  NOT_LIKE: "不像"
};

export enum DimensionTypeEnum {
  dimension = "dimension",
  agg = "agg",
  indicators = "indicators"
}

export enum ColumnTypeEnum {
  date = "date",
  number = "number",
  string = "string"
}

export const DateRange = [
  { label: "当天", value: "0_day" },
  { label: "本周", value: "0_week" },
  { label: "本月", value: "0_month" }
];

export enum SymbolEnum {
  AVG = "AVG",
  COUNT = "COUNT",
  DISTINCT_COUNT = "DISTINCT_COUNT",
  EQ = "EQ",
  GE = "GE",
  GT = "GT",
  IN = "IN",
  IS_NOT_NULL = "IS_NOT_NULL",
  IS_NULL = "IS_NULL",
  LE = "LE",
  LIKE = "LIKE",
  LT = "LT",
  MAX = "MAX",
  MIN = "MIN",
  NE = "NE",
  NOT_IN = "NOT_IN",
  NOT_LIKE = "NOT_LIKE",
  SUM = "SUM"
}

export const ColumnDimensionType = [
  // 维度类型，indicators ，dimension
  {
    label: "维度",
    value: DimensionTypeEnum.dimension,
    children: [
      {
        value: DimensionExtraEnum.normal,
        label: "普通"
      },
      {
        value: DimensionExtraEnum.dimension_primary_key,
        label: "主键"
      }
    ]
  },
  {
    label: "数值",
    value: DimensionTypeEnum.indicators,
    children: [
      {
        value: DimensionExtraEnum.indicators_input,
        label: "input"
      },
      {
        value: DimensionExtraEnum.indicators_textarea,
        label: "textarea"
      },
      {
        value: DimensionExtraEnum.indicators_image,
        label: "image"
      },
      {
        value: DimensionExtraEnum.indicators_file,
        label: "file"
      },
      {
        value: DimensionExtraEnum.indicators_password,
        label: "password"
      }
    ]
  },
  {
    label: "聚合",
    value: DimensionTypeEnum.agg,
    children: [
      {
        value: DimensionExtraEnum.agg_count,
        label: "计数"
      },
      {
        value: DimensionExtraEnum.agg_distinct_count,
        label: "去重计数"
      },
      {
        value: DimensionExtraEnum.agg_sum,
        label: "求和"
      },
      {
        value: DimensionExtraEnum.agg_max,
        label: "最大值"
      },
      {
        value: DimensionExtraEnum.agg_avg,
        label: "平均值"
      },
      {
        value: DimensionExtraEnum.agg_min,
        label: "最小值"
      }
    ]
  }
];

// date = "日",
//   datetime = "日期时间",
//   daterange = "日期区间",
//   datetimerange = "日期时间区间",
//   month = "月",
//   monthrange = "月区间",
//   year = "年",
//   week = "周"
export const DatePickerType = [
  { value: "date", label: "date", format: "YYYY-MM-DD" },
  { value: "datetime", label: "date-time", format: "YYYY-MM-DD HH:mm:ss" },
  { value: "daterange", label: "date-range", format: "YYYY-MM-DD" },
  { value: "datetimerange", label: "date-time-range", format: "YYYY-MM-DD HH:mm:ss" },
  { value: "month", label: "month", format: "YYYY-MM" },
  { value: "monthrange", label: "month-range", format: "YYYY-MM" },
  { value: "year", label: "年", format: "YYYY" }
];

export const DatePickerFormat = DatePickerType.reduce((obj: { [key: string]: string }, item) => {
  obj[item.value] = item.format;
  return obj;
}, {});

export const ColumnDimensionTypes: { [key: string]: any } = {
  date: [
    // 维度类型，indicators ，dimension
    {
      label: "维度",
      value: DimensionTypeEnum.dimension,
      children: DatePickerType
    },
    {
      label: "数值",
      value: DimensionTypeEnum.indicators,
      children: DatePickerType
    }
  ],
  string: [
    // 维度类型，indicators ，dimension
    {
      label: "维度",
      value: DimensionTypeEnum.dimension,
      children: [
        {
          value: DimensionExtraEnum.normal,
          label: "普通"
        },
        {
          value: DimensionExtraEnum.dimension_primary_key,
          label: "主键"
        }
      ]
    },
    {
      label: "数值",
      value: DimensionTypeEnum.indicators,
      children: [
        {
          value: DimensionExtraEnum.indicators_input,
          label: "输入框"
        },
        {
          value: DimensionExtraEnum.indicators_textarea,
          label: "文本域"
        },
        {
          value: DimensionExtraEnum.indicators_richText,
          label: "富文本"
        },
        {
          value: DimensionExtraEnum.indicators_image,
          label: "图片"
        },
        {
          value: DimensionExtraEnum.indicators_file,
          label: "文件"
        },
        {
          value: DimensionExtraEnum.indicators_password,
          label: "密码"
        }
      ]
    },
    {
      label: "聚合",
      value: DimensionTypeEnum.agg,
      children: [
        {
          value: DimensionExtraEnum.agg_count,
          label: "计数"
        },
        {
          value: DimensionExtraEnum.agg_distinct_count,
          label: "去重计数"
        },
        {
          value: DimensionExtraEnum.agg_sum,
          label: "求和"
        },
        {
          value: DimensionExtraEnum.agg_max,
          label: "最大值"
        },
        {
          value: DimensionExtraEnum.agg_avg,
          label: "平均值"
        },
        {
          value: DimensionExtraEnum.agg_min,
          label: "最小值"
        }
      ]
    }
  ],
  number: [
    // 维度类型，indicators ，dimension
    {
      label: "维度",
      value: DimensionTypeEnum.dimension,
      children: [
        {
          value: DimensionExtraEnum.normal,
          label: "普通"
        },
        {
          value: DimensionExtraEnum.dimension_primary_key,
          label: "主键"
        }
      ]
    },
    {
      label: "数值",
      value: DimensionTypeEnum.indicators,
      children: [
        {
          value: DimensionExtraEnum.indicators_input,
          label: "input"
        }
      ]
    },
    {
      label: "聚合",
      value: DimensionTypeEnum.agg,
      children: [
        {
          value: DimensionExtraEnum.agg_count,
          label: "计数"
        },
        {
          value: DimensionExtraEnum.agg_distinct_count,
          label: "去重计数"
        },
        {
          value: DimensionExtraEnum.agg_sum,
          label: "求和"
        },
        {
          value: DimensionExtraEnum.agg_max,
          label: "最大值"
        },
        {
          value: DimensionExtraEnum.agg_avg,
          label: "平均值"
        },
        {
          value: DimensionExtraEnum.agg_min,
          label: "最小值"
        }
      ]
    }
  ]
};

export enum DimensionAdvanced {
  multi_select = "multi_select"
}
